Skip to content

SANDBOX-808: update kube & openshift dependencies to 4.17 #1146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

rsoaresd
Copy link
Contributor

@rsoaresd rsoaresd commented Feb 19, 2025

Description

Update dependencies

Tool/Library Current Version Updates to Version
Golang 1.21 1.22
Operator SDK 1.36 1.38
k8s.io/* v0.29.2 v0.30.1
controller-runtime v0.17.3 v0.18.4

Note

Operator SDK will be updated in the next set of PRs along with toolchain-cicd and operators update

Issue ticket number and link

SANDBOX-808

Note

snyk reports a lot of vulnerabilities regarding go 1.22. From snyk's source, it seems all FPs. For more info, check this Slack thread

@rsoaresd rsoaresd force-pushed the openshift_4_17-host-operator branch from 106e06b to a9ffa09 Compare February 19, 2025 16:12
Copy link
Contributor

@ranakan19 ranakan19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍
I would love to use the generic functions to propagate the object type into the specific predicates & mappers. This can be done as a separate task though - in a separate PR, let's just create a story for it.

Comment on lines +51 to +53
source.Kind[runtimeclient.Object](memberCluster.Cache, &toolchainv1alpha1.SpaceBindingRequest{},
&handler.EnqueueRequestForObject{},
predicate.GenerationChangedPredicate{}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, there are typed versions of the handlers and predicates, so you can use it:

source.Kind(memberCluster.Cache, &toolchainv1alpha1.SpaceBindingRequest{},
	&handler.TypedEnqueueRequestForObject[*toolchainv1alpha1.SpaceBindingRequest]{},
	predicate.TypedGenerationChangedPredicate[*toolchainv1alpha1.SpaceBindingRequest]{}))

but I'm not sure if it makes any sense in this particular case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I tried that way when I saw that we needed to refactor the code. It gives this error:

type predicate.TypedGenerationChangedPredicate[*v1alpha1.SpaceBindingRequest] of predicate.TypedGenerationChangedPredicate[*toolchainv1alpha1.SpaceBindingRequest]{} does not match predicate.TypedPredicate[T] (cannot infer T)compilerCannotInferTypeArgs

Comment on lines +50 to +52
b = b.WatchesRawSource(source.Kind[runtimeclient.Object](memberCluster.Cache, &toolchainv1alpha1.UserAccount{},
handler.EnqueueRequestsFromMapFunc(mapper.MapByResourceName(r.Namespace)),
)
))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably not really related to this particular case since the mapper is generic, but there a function

handler.TypedEnqueueRequestsFromMapFunc

that takes the type provided in the source.Kind function and use it as the generics to provide the same type down to the mapper and predicate. This can be very useful in the mappers and predicates that are specific to resource kind like this one:

func MapBannedUserToUserSignup(cl runtimeclient.Client) func(ctx context.Context, object runtimeclient.Object) []reconcile.Request {
var logger = ctrl.Log.WithName("BannedUserToUserSignupMapper")
return func(ctx context.Context, obj runtimeclient.Object) []reconcile.Request {
if bu, ok := obj.(*toolchainv1alpha1.BannedUser); ok {

or this one:
func MapToolchainStatusToSpaceProvisionerConfigs(cl runtimeclient.Client) func(context.Context, runtimeclient.Object) []reconcile.Request {
return func(ctx context.Context, obj runtimeclient.Object) []reconcile.Request {
if _, ok := obj.(*toolchainv1alpha1.ToolchainStatus); !ok {
return nil
}

and there will be a few more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean replacing EnqueueRequestsFromMapFunc with TypedEnqueueRequestsFromMapFunc on those calls and refactoring the code?

Copy link

openshift-ci bot commented Feb 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexeykazakov, fbm3307, MatousJobanek, ranakan19, rsoaresd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [MatousJobanek,alexeykazakov,fbm3307,ranakan19,rsoaresd]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rsoaresd
Copy link
Contributor Author

rsoaresd commented Mar 5, 2025

Looks good 👍 I would love to use the generic functions to propagate the object type into the specific predicates & mappers. This can be done as a separate task though - in a separate PR, let's just create a story for it.

@MatousJobanek thank you so much! https://issues.redhat.com/browse/SANDBOX-1022

Copy link

@rsoaresd rsoaresd merged commit 5a1e5ca into codeready-toolchain:master Mar 14, 2025
12 of 15 checks passed
Copy link

codecov bot commented Mar 14, 2025

Codecov Report

Attention: Patch coverage is 8.33333% with 11 lines in your changes missing coverage. Please review.

Project coverage is 79.68%. Comparing base (62dcb7b) to head (506102f).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
controllers/space/space_controller.go 0.00% 3 Missing ⚠️
...cebindingrequest/spacebindingrequest_controller.go 0.00% 3 Missing ⚠️
...ontrollers/spacerequest/spacerequest_controller.go 0.00% 3 Missing ⚠️
...rs/masteruserrecord/masteruserrecord_controller.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1146   +/-   ##
=======================================
  Coverage   79.68%   79.68%           
=======================================
  Files          82       82           
  Lines        8245     8245           
=======================================
  Hits         6570     6570           
  Misses       1479     1479           
  Partials      196      196           
Files with missing lines Coverage Δ
test/spacebinding/spacebinding_assertions.go 88.23% <100.00%> (ø)
...rs/masteruserrecord/masteruserrecord_controller.go 80.64% <0.00%> (ø)
controllers/space/space_controller.go 85.98% <0.00%> (ø)
...cebindingrequest/spacebindingrequest_controller.go 84.47% <0.00%> (ø)
...ontrollers/spacerequest/spacerequest_controller.go 87.79% <0.00%> (ø)
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants